#define _CRT_SECURE_NO_WARNINGS 1
#include"Stack.h"


void Stack::Init(int n)
{
	
	_a = (int*)malloc(n * sizeof(int));
	if (_a == NULL)
	{
		perror("malloc fail");
		return;
	}
	_top = 0;
	_capacity = n;
}
void Stack::Push(int x)
{
	_a[_top++] = x;
}
void Stack::Pop()
{
	assert(!Empty());
	--_top;

}
bool Stack::Empty()
{
	return _top == 0;
}

void Stack::Destroy()
{
	free(_a);
	_a = nullptr;
	_top = _capacity = 0;
}